package com.example.mapper;

import com.example.pojo.Production;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ProductionMapper {
    @Select("select count(*) from productions where name=#{name}")
    int select(String name);
@Insert("insert into productions (name,num,price,unit) values (#{name},#{num},#{price},#{unit})")
    void add(Production production);
@Update("update productions set num=num+#{num} where name = #{name}")
    void update(Production production);

    Long count(String name, int num);

    List<Production> page(Integer start, Integer pageSize, String name, int num);
    @Update("update productions set num=#{num},price=#{price} where id = #{id}")
    void updates(Production production);
@Select("select num from productions where name=#{productName}")
    int getNum(String productName);
@Update("update productions set num=num-#{num} where name=#{productName}")
    void updatef(String productName, int num);
@Select("select * from productions")
    List<Production> getAll();
    @Select("select count(*) from productions where name=#{productName}")
    Boolean existsByName(String productName);
}
